#!/usr/bin/env python

import wx
from _base import Base

class Main(Base):
    '''Main class
    
    @author Julot <andy.julot@gmail.com>
    @since Saturday, January 14, 2012. 09:04 AM'''
    
    def bind(self):
        super(Main, self).bind()
        
        view = self.view
        menu = view.MenuBar
        tool = view.ToolBar
        
        view.Bind(wx.EVT_MENU, self.close, menu.file.close)
        view.Bind(wx.EVT_MENU, self.showAbout, menu.help.about)
        view.Bind(wx.EVT_MENU, self.browse, menu.file.browse)
        
        view.Bind(wx.EVT_MENU, self.close, tool.close.tool)
        view.Bind(wx.EVT_MENU, self.showAbout, tool.about.tool)
        view.Bind(wx.EVT_MENU, self.browse, tool.browse.tool)
        view.Bind(wx.EVT_MENU, self.upload, tool.upload.tool)
        
        view.Bind(wx.EVT_COMBOBOX, self.onManga, view.form.manga)
    
    def close(self, event):
        self.presenter.close()
        event.Skip()
    
    def showAbout(self, event):
        self.presenter.showAbout()
        event.Skip()
    
    def browse(self, event):
        self.presenter.browse()
        event.Skip()
    
    def onManga(self, event):
        manga = self.view.form.manga.value
        self.presenter.populateChapter(manga)
        event.Skip()
    
    def upload(self, event):
        self.presenter.upload()
        event.Skip()